/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package org.osdtsystem.functions;

import org.osdtsystem.graphs.GraphAccessor;

/**
 *
 * @author matthias
 */
public class FuncStrlen extends AbstractSingletonFunction<Integer> {
    SingletonFunction<? extends String> subfunction;

    FuncStrlen(SingletonFunction<? extends String> subfunction) {
        super(subfunction);
        this.subfunction = subfunction;
    }

    @Override
    public Integer _singletonFunctionValue(LocalFunction<?, ?> caller, FunctionContext context, GraphAccessor accessor) {
        String string = subfunction.singletonFunctionValue(caller, context, accessor);
        return string.length();
    }

    @Override
    void toStringBuilder(FunctionStringBuilder builder) {
        builder.addSubfunction(subfunction);
    }
}
